package com.yl.utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Utils {
    public static LocalDateTime formatDateTime(String pTime){
        if(pTime != null && pTime.indexOf("-")>0 && pTime.indexOf(":")>0) {
            LocalDateTime sqlDate = LocalDateTime.parse(pTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            return sqlDate;
        }
        return null;
    }

    public static LocalDate formatDate(String pTime){
        if(pTime != null && pTime.indexOf("-")>0) {
            LocalDate sqlDate = LocalDate.parse(pTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            return sqlDate;
        }
        return null;
    }
}
